(function(){
/**
 * Core methods
 *
 * Created by JetBrains PhpStorm
 * User: Semen Kamenetskiy <s-kamen@mail.ru>
 * Date: 5/17/13
 * Time: 9:47 AM
 */

/**
 * Sets a global variable in the "window" object
 * @param key
 * @param value
 * @returns {*}
 * @private
 */
function __setGlobal(key, value) {
    window[key] = value;
    return window[key];
}

/**
 * Gets a global variable
 * @param key
 * @returns {*|undefined}
 * @private
 */
function __getGlobal(key) {
    return window[key] || undefined;
}
/**
 * Core methods
 *
 * Created by JetBrains PhpStorm
 * User: Semen Kamenetskiy <s-kamen@mail.ru>
 * Date: 5/17/13
 * Time: 9:47 AM
 */

/**
 * Sets a global variable in the "window" object
 * @param key
 * @param value
 * @returns {*}
 * @private
 */
function __setGlobal(key, value) {
    window[key] = value;
    return window[key];
}

/**
 * Gets a global variable
 * @param key
 * @returns {*|undefined}
 * @private
 */
function __getGlobal(key) {
    return window[key] || undefined;
}
/**
 * XSLT
 *
 * Created by JetBrains PhpStorm
 * User: Semen Kamenetskiy <s-kamen@mail.ru>
 * Date: 5/16/13
 * Time: 11:53 AM
 */

(function () {

    var XSLT = Backbone.Model.extend({

        constructor: function(){
            alert('hello world');
        }

    });

    __setGlobal('XSLT', XSLT);

}());
/**
 * XSLT_Loader
 *
 * Created by JetBrains PhpStorm
 * User: Semen Kamenetskiy <s-kamen@mail.ru>
 * Date: 5/17/13
 * Time: 9:53 AM
 */
(function () {

    /**
     * Creates a new XMLHttpRequest
     * @returns {boolean|XMLHttpRequest}
     * @private
     */
    function __getXmlHttpRequest() {
        var request = false;

        if (XMLHttpRequest) {
            request = new XMLHttpRequest();
        }
        else if (ActiveXObject) {
            try {
                request = new ActiveXObject('Msxml2.XMLHTTP')
            }
            catch (e) {
                try {
                    request = new ActiveXObject('Microsoft.XMLHTTP')
                }
                catch (e) {
                }
            }
        }

        if (false === request) {
            throw new Error('XSLT_Loader: Your browser does not seem to support XML HTTP requests.');
        }

        return request;
    }

    /**
     * Allowed XMLHttpRequest methods
     * @type {Array}
     * @private
     */
    var __allowedXmlHttpMethods = ['GET', 'POST'];

    /**
     *
     * @type {*|void}
     */
    var XSLT_Loader = Backbone.Model.extend({

        /**
         * Object constructor
         * @constructor
         */
        constructor: function () {
            console.log(this);
            this.set({__xhr: __getXmlHttpRequest()});

        },

        /**
         * Contains XMLHttpRequest
         * @type {null|XMLHttpRequest}
         * @private
         */
        __xhr: null,

        /**
         * Contains XMLHttpRequest method
         */
        __xhrMethod: 'GET',

        /**
         * Sets XMLHttpRequest method
         * @param method
         * @returns {XSLT_Loader}
         */
        setMethod: function (method) {
            this.set({__xhrMethod: method || 'GET'});
            return this;
        }
    });

    __setGlobal('XSLT_Loader', XSLT_Loader);

}());
/**
 * XSLT_Template
 *
 * Created by JetBrains PhpStorm
 * User: Semen Kamenetskiy <s-kamen@mail.ru>
 * Date: 5/16/13
 * Time: 11:54 AM
 */

(function () {

    var  XSLT_Template = Backbone.Model.extend({

        /**
         * Object constructor
         * @constructor
         */
        constructor: function(){
            alert('hello world');
        }

    });



    __setGlobal('XSLT_Template', XSLT_Template);

}());
}());
